﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using UIWindows.Models.Devices;
using XingLucifer.IBase.Enums;
using System.Windows.Controls;
using MaterialDesignThemes.Wpf;
using UIWindows.Enums;

namespace UIWindows.ViewModels.Dialogs
{
    public class DeviceModifyVModel
    {
        public ObservableCollection<string> ServiceNameList { get; set; }
        public IEnumerable<TaskTypes> TaskTypeList
        {
            get
            {
                foreach (TaskTypes c in (TaskTypes[])Enum.GetValues(typeof(TaskTypes)))
                {
                    yield return c;
                }
            }
        }
        public IEnumerable<DeviceTypes> Foods
        {
            get
            {
                foreach (DeviceTypes c in (DeviceTypes[])Enum.GetValues(typeof(DeviceTypes)))
                {
                    yield return c;
                }
            }
        }
        public IEnumerable<int> IndexList
        {
            get {
                for (int i = 0; i < 33; i++)
                {
                    yield return i;
                }
            }
        }
        public DeviceClientModel DCModel { get; set; }
        public GlobalStatics.DeviceConfigStatic _deviceConfig;
        public DeviceModifyVModel(DeviceClientModel model, GlobalStatics.SystemConfigStatic systemConfig, GlobalStatics.DeviceConfigStatic deviceConfig)
        {
            DCModel = model;
            _deviceConfig = deviceConfig;
            ServiceNameList = new ObservableCollection<string>();
            foreach (var item in systemConfig.SignalList)
            {
                ServiceNameList.Add(item.Name);
            }
        }

        public Commands.DelegateCommand<string> SaveDelete => new Commands.DelegateCommand<string>(sender =>
        {
            if (sender != null)
            {
                switch (sender)
                {
                    case "删除":
                        _deviceConfig.DeviceList.Remove(DCModel);
                        break;
                }
                _deviceConfig.Save();
                if (DialogHost.IsDialogOpen(PopUpTypes.Global.ToString())) { DialogHost.Close(PopUpTypes.Global.ToString()); }
            }
        });
    }
}
